document.documentElement.id = "js";
$(document).ready(function(){
	
	/*$('#c1-close-button').click(function(){
		$('#c1-user-form').addClass('c1-hidden');
	});*/
	
	/*$('.gamelist').jScrollPane({showArrows:true, scrollbarWidth: 11});*/
	
	$('.answer-comment').click(function(e){
		e.preventDefault();
		showAnswerForm(this, true);
	});
	
	$('.comments-plus').click(function(e)
	{
		e.preventDefault();
		changeRating(this, 1);
	});
	
	$('.comments-minus').click(function(e)
	{
		e.preventDefault();
		changeRating(this, -1);
	});
	
	$('.comments-ban').click(function(e)
	{
		e.preventDefault();
		showBanWindow(this);
	});
	
	$('.comments-warn').click(function(e)
	{
		e.preventDefault();
		showWarnWindow(this);
	});
	
	$('.comments-options-del').click(function(e)
	{
		e.preventDefault();
		showDelWindow(this);
	});
	
	$('.comments-options-edit').click(function(e)
	{
		e.preventDefault();
		showEditWindow(this);
	});
	
	
	$('.comments-clear').click(function(e)
	{
		e.preventDefault();
		showClearWindow(this);
	});
	
	$('a.modalCloseImg').click(function(e){
		$('#comments-sending').find('.cn-content').remove();
	});
	
	$('.cn-content .b-expand_comment').addClass('hidden');
	$('.cn-content .comments-message-expand').click(function(){
		expandComment(this);
	});
	
	$('.comments-editblock-close').live('click', function(e)
	{
		e.preventDefault();
		removeEditForm(this);
	});
	
	$('.b-comment-add_link').click(function(e){
		e.preventDefault();
		showCommentNewForm(true);
	});
	
	$('.comments-answerblock-close').live('click',function(e){
		e.preventDefault();
		removeAnswerForm(this);
	});


	/*
	$(function(){
	
		$.extend($.fn.jScrollPane.defaults, {
			showArrows:true,
			scrollbarWidth:11
			}
		);

		var isResizing;
		
		// and the body scrollpane
		var setContainerWidth = function()
		{
			// IE triggers the onResize event internally when you do the stuff in this function
			// so make sure we don't enter an infinite loop and crash the browser
			if (!isResizing) { 
				isResizing = true;
				$w = $('.c1-games');
				$c = $('.gamelist');
				$jscpn = $('div.c1-games>div.jScrollPaneContainer');
				var p = (parseInt($c.css('paddingLeft')) || 0) + (parseInt($c.css('paddingRight')) || 0);
				$jscpn.css({'width': $w.width() + 'px'});
				$c.css({'width': ($w.width() - p) + 'px', 'overflow':'auto'});
				$c.jScrollPane();
				isResizing = false;	
			}
		}
		$(window).bind('resize', setContainerWidth);
		setContainerWidth();
		
			// it seems like you need to call this twice to get consistantly correct results cross browser...
		setContainerWidth();
	});
	*/


	$(function () {
		var tabContainers = $('.b-profile-tabs > div'); // получаем массив контейнеров
		tabContainers.hide().filter(':first').show(); // прячем все, кроме первого
		// далее обрабатывается клик по вкладке
		$('.b-profile-tabs .b-profile-tabNavigation a').click(function () {
			tabContainers.hide(); // прячем все табы
			tabContainers.filter(this.hash).show(); // показываем содержимое текущего
			$('.b-profile-tabs .b-profile-tabNavigation a').removeClass('selected'); // у всех убираем класс 'selected'
			$(this).addClass('selected'); // текушей вкладке добавляем класс 'selected'
			return false;
		}).filter(':first').click();
	});
	
	$(function(){
		$('.slide').click(function(){
			slide(this);
		})
	})
	
	$(function(){
		var liTurNav = $('#tur_navigation').children();
		for (i =0; i < liTurNav.length; i++){
			//alert(liTurNav.children());
			var AWidth = liTurNav.eq(i).children().width();
			if (AWidth < 20) {
				//alert(AWidth+' '+i);
				liTurNav.eq(i).children().css({'width':'20px'});
			} else {}
		}
	})
	
	$(function(){
		$('.albom').innerfade({ 
			speed: 'slow', 
			timeout:10000, 
			type: 'sequence', 
			containerheight: '220px' 
		}); 
	})
	
	$(function(){
		$('.albom-otchet').innerfade({ 
			speed: 'slow', 
			timeout:10000, 
			type: 'sequence', 
			containerheight: '170px' 
		}); 
	})
	
	/* $(function (){
		$('#tur_navigation li a').oltooltip('tooltip');
		$('#albom_foto li a').oltooltip('num_game');
	}) */
	
	$(function (){
		var city_inp = $('#city_other');
		$('#city').change(function(){
			if ($('#city').val() =='other'){ 
				$(city_inp).show()
			}else $(city_inp).hide();
		});
	});
	
	$(function(){
		$("#inputDate").mask('99.99.9999', {placeholder:" "});
	});
});

$(function showLoginForm(){

	$(".c1-display-login-form").click(function(){
		$("#c1-user-form").modal({
			opacity:30,
			overlayClose:true
		});
		return false;
	});
	
});

function slide(obj){	
	$(obj).each(function()
		{
			var list = $(obj).parent().parent().find('.b-list-game');
			var arrow = $(obj).parent().parent().find('.arrow-top');
			list.hide(300).addClass('b-hidden');
			arrow.hide(300).addClass('b-hidden');
			$(obj).removeClass('b-selected');
		});
	
	var list = $(obj).parent().parent().find('.b-list-game');
	var arrow = $(obj).parent().parent().find('.arrow-top');
	
	if ('none' == list.css('display'))
		{
			list.show(300).removeClass('b-hidden');
			arrow.show(300).removeClass('b-hidden');
			$(obj).addClass('b-selected');
			
			
			setTimeout(function()
			{
				$(window).scrollTop($(obj).offset().top - 20);
			}, 300);
		}
}

// Функции комментариев

	function link_to_post(url)
	{
		prompt("Копирование прямой ссылки на комментарий для сохранения в буфере объекта", url);
	}

	/*
	var answerBlock = '<div id="comments-answerblock" class="comments-answerblock">\
	<div id="link_post_div">\
		<form id="link_post_form" class="comments-sending" action="/cgi-bin/MainNews/index.cgi#after_comments" method="post">\
		<div class="comments-message">\
			<p><textarea name="comment_text" row="5" col="10" class="comments-sending-textarea"></textarea></p>\
			<p class="b-form-button"><input type="submit" value="Ответить"/></p>\
		</div>\
		</form>\
	</div>\
	</div>';
	*/

	function expandComment(obj){
		var ShowCommentCommand = $(obj).parent().find('.comments-message-expand');
		var CommentText = $(obj).parent().parent().find('.b-expand_comment');
		$(obj).parent().hide('fast');
		CommentText.show(600).removeClass('hidden');
	}
	
	function showCommentNewForm(setFocus){
		if (setFocus == undefined){setFocus = true}
		var parAnswerBlockOptions = $('#comments-answerblock').parent().find('.comments-options');
		$(parAnswerBlockOptions).show();
		$('.comments-wrap #comments-answerblock').remove();
		$('.comments-answerblock_main').show().find('textarea').focus();
	}
	
	function showAnswerForm (obj, setFocus){
		//setFocus = setFocus == undefined ? true : setFocus;
		if (setFocus == undefined){setFocus = true}
		
		var answerBlock = $('#comments-answerblock').clone();
		var parAnswerBlockOptions = $('#comments-answerblock').parent().find('.comments-options');
		var mainForm = $('.comments-answerblock_main');
		
		$(parAnswerBlockOptions).show();
		$('.comments-wrap #comments-answerblock').remove();
		
		var vis_mainForm = $(mainForm).css('display');
		
		if (vis_mainForm == 'block') {
			$(mainForm).hide();
		}
		
		var comment_idTable = $(obj).parent().parent().parent().parent().parent().attr('id');
		comment_id = comment_idTable.replace(/comment_/i, ''); //id commenta
		
		var commentForm = $(answerBlock).find('.comments-sending');
		var action = $(commentForm).attr('action');
		var pos = action.indexOf('#');
		
		action = action.substr(0, pos);
		$(commentForm).attr('action', action+"#comment_"+comment_id);
		$(commentForm).find('.comments-message').find('#message_id').remove();
		$(commentForm).find('.comments-message').append('<input type="hidden" name="message_id" id="message_id" value="'+comment_id+'" />');
		
		var parentAnchor = $(obj).parent();
		$(parentAnchor).hide();
		$(parentAnchor).after($(answerBlock));
		$(answerBlock).find('textarea').focus();
		
		/* 
		div_comment_wrap = $('<div></div>').addClass('comment_wrap').css({display:'none'}).appendTo('body');
		var comment_wrap = $('.comment_wrap');
		var comment = $(obj).parent().parent().find('.cn-content');
		var comment_id = $(comment).find('.message_id');
		var commentForm = $('.comments-sending').clone();
		var action = $(commentForm).attr('action');
		var pos = action.indexOf('#');
		action = action.substr(0, pos);
		$(commentForm).attr('action', action+"#comment"+$(comment_id).text());
		$(commentForm).find('.b-form-button').append('<input class="simplemodal-close" type="button" value="Отказаться" />');
		$(commentForm).find('.comments-message').append('<input type="hidden" name="message_id" value="'+$(comment_id).text()+'" />');
		$(comment).clone().prependTo($(commentForm));
		$(commentForm).appendTo($(comment_wrap));
		$(comment_wrap).modal();
		$('a.modalCloseImg').click(function(e){
			$(comment_wrap).remove();
		}); */
	}
	
	function removeCommentfromFormblock(){
		$('#comments-sending').find('.cn-content').remove();
	}
	
	function showBanWindow(obj){
		var banForm = $('.ban_form').clone();
		var comment = $(obj).parent().parent().parent().parent().find('.cn-content');
		var comment_idTable = $(obj).parent().parent().parent().parent().parent().parent().attr('id');
		var comment_id = comment_idTable.replace(/comment_/i, ''); //id commenta
		var action = $(banForm).attr('action');
		$(banForm).attr('action', action+"#comment_"+comment_id);
		$(banForm).find('#message_id').val(comment_id);
		$(banForm).modal();
	}
	
	function showWarnWindow(obj){
		var warnForm = $('.warn_form').clone();
		var comment = $(obj).parent().parent().parent().parent().parent().find('.cn-content');
		var comment_idTable = $(obj).parent().parent().parent().parent().parent().parent().attr('id');
		var comment_id = comment_idTable.replace(/comment_/i, ''); //id commenta
		var action = $(warnForm).attr('action');
		$(warnForm).attr('action', action+"#comment_"+comment_id);
		$(warnForm).find('#message_id').val(comment_id);
		$(warnForm).modal();
	}
	
	function showDelWindow(obj){
		var delForm = $('.del_form').clone();
		var comment = $(obj).parent().parent().find('.cn-content');
		var comment_idTable = $(obj).parent().parent().parent().parent().parent().attr('id');
		var comment_id = comment_idTable.replace(/comment_/i, ''); //id commenta
		$(delForm).find('#message_id').val(comment_id);
		$(delForm).modal();
	}
	
	function showEditWindow(obj){
		/*var editForm = $('.edit_form').clone();
		var comment = $(obj).parent().parent().find('.cn-content');
		var comment_id = $(comment).find('.message_id');
		var action = $(editForm).attr('action');
		$(editForm).attr('action', action+"#comment"+$(comment_id).text());
		$(editForm).find('#message_id').val($(comment_id).text());
		$(editForm).find('.comments-sending-textarea').text($(comment).find('.comments-text').text());
		$(editForm).modal();
		*/
		
		var editBlock =  $('.comments-editblock').clone();
		$('#comments-editblock').remove();
		var comment = $(obj).parent().parent().find('.cn-content');
		var comment_idTable = $(obj).parent().parent().parent().parent().parent().attr('id');
		var comment_id = comment_idTable.replace(/comment_/i, ''); //id commenta
		var editForm = $(editBlock).find('.edit_form');
		var action = $(editForm).attr('action');
		$(editForm).attr('action', action+"#comment_"+comment_id);
		$(editForm).find('#message_id').val(comment_id);
		$(editForm).find('.comments-sending-textarea').val($(comment).find('.comments-text').text());
		var parentAnchor = $(obj).parent();
		$(comment).hide();
		$(parentAnchor).hide();
		$(parentAnchor).after($(editBlock));
		$(editBlock).find('textarea').focus();
		
	};
	
	function showClearWindow(obj){
		var editForm = $('.clear_form').clone();
		$(editForm).modal();
	};
	
	function changeRating(obj, flag_plus){
		var comment = $(obj).parent().parent().parent().parent().find('.cn-content');
		var comment_idTable = $(obj).parent().parent().parent().parent().parent().parent().attr('id');
		var comment_id = comment_idTable.replace(/comment_/i, '');
		var object_id = "";
		var object = $(obj).parent().parent().parent().parent().parent().parent();
		while (!object_id)
		{
			object_id = object.find('.curr_obj_id').text();
			object = object.parent();
		}
		var change_str;
		if (flag_plus == 1)
		{
			change_str = "plus";
		}
		else
		{
			change_str = "minus";
		}
		$.ajax({  
			type: "GET",  
			data: "ajax=1&object_id="+object_id+"&comment_action="+change_str+"&message_id="+comment_id,  
			url: "/cgi-bin/iReg/comment_rating.cgi" ,
			success: function(data) {
				if (data == "1")
				{
					$(obj).parent().hide();
					var rating = parseInt($(obj).parent().parent().find('.comment-rating').text());
					$(obj).parent().parent().find('.comment-rating').text(rating+flag_plus);
				}
			}
		});
	};
	
	function removeEditForm(obj){
		var pForm = $(obj).parentsUntil('tr').find('#comments-editblock').clone();
		var optionP = $(obj).parentsUntil('tr').find('.comments-options');
		var editMes = $(obj).parentsUntil('tr').find('.cn-content');

		$('#comments-editblock').remove();
		$(pForm).appendTo('#edit_div');
		$(editMes).show();
		$(optionP).show();
	};
	
	function removeAnswerForm(obj){
		var answerForm = $(obj).parentsUntil('tr').find('.comments-answerblock');
		var optionP = $(obj).parentsUntil('tr').find('.comments-options');
		$(answerForm).remove();
		$(optionP).show();
	}





/* jScrollPane */
/*
(function($) {

$.jScrollPane = {
	active : []
};
$.fn.jScrollPane = function(settings)
{
	settings = $.extend({}, $.fn.jScrollPane.defaults, settings);

	var rf = function() { return false; };
	
	return this.each(
		function()
		{
			var $this = $(this);
			// Switch the element's overflow to hidden to ensure we get the size of the element without the scrollbars [http://plugins.jquery.com/node/1208]
			$this.css('overflow', 'hidden');
			var paneEle = this;
			
			if ($(this).parent().is('.jScrollPaneContainer')) {
				var currentScrollPosition = settings.maintainPosition ? $this.position().top : 0;
				var $c = $(this).parent();
				var paneWidth = $c.innerWidth();
				var paneHeight = $c.outerHeight();
				var trackHeight = paneHeight;
				$('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown', $c).remove();
				$this.css({'top':0});
			} else {
				var currentScrollPosition = 0;
				this.originalPadding = $this.css('paddingTop') + ' ' + $this.css('paddingRight') + ' ' + $this.css('paddingBottom') + ' ' + $this.css('paddingLeft');
				this.originalSidePaddingTotal = (parseInt($this.css('paddingLeft')) || 0) + (parseInt($this.css('paddingRight')) || 0);
				var paneWidth = $this.innerWidth();
				var paneHeight = $this.innerHeight();
				var trackHeight = paneHeight;
				$this.wrap(
					$('<div></div>').attr(
						{'className':'jScrollPaneContainer'}
					).css(
						{
							'height':paneHeight+'px', 
							'width':paneWidth+'px'
						}
					)
				);
				// deal with text size changes (if the jquery.em plugin is included)
				// and re-initialise the scrollPane so the track maintains the
				// correct size
				$(document).bind(
					'emchange', 
					function(e, cur, prev)
					{
						$this.jScrollPane(settings);
					}
				);
				
			}
			
			if (settings.reinitialiseOnImageLoad) {
				// code inspired by jquery.onImagesLoad: http://plugins.jquery.com/project/onImagesLoad
				// except we re-initialise the scroll pane when each image loads so that the scroll pane is always up to size...
				// TODO: Do I even need to store it in $.data? Is a local variable here the same since I don't pass the reinitialiseOnImageLoad when I re-initialise?
				var $imagesToLoad = $.data(paneEle, 'jScrollPaneImagesToLoad') || $('img', $this);
				var loadedImages = [];
				
				if ($imagesToLoad.length) {
					$imagesToLoad.each(function(i, val)	{
						$(this).bind('load', function() {
							if($.inArray(i, loadedImages) == -1){ //don't double count images
								loadedImages.push(val); //keep a record of images we've seen
								$imagesToLoad = $.grep($imagesToLoad, function(n, i) {
									return n != val;
								});
								$.data(paneEle, 'jScrollPaneImagesToLoad', $imagesToLoad);
								settings.reinitialiseOnImageLoad = false;
								$this.jScrollPane(settings); // re-initialise
							}
						}).each(function(i, val) {
							if(this.complete || this.complete===undefined) { 
								//needed for potential cached images
								this.src = this.src; 
							} 
						});
					});
				};
			}

			var p = this.originalSidePaddingTotal;
			
			var cssToApply = {
				'height':'auto',
				'width':paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p + 'px'
			}

			if(settings.scrollbarOnLeft) {
				cssToApply.paddingLeft = settings.scrollbarMargin + settings.scrollbarWidth + 'px';
			} else {
				cssToApply.paddingRight = settings.scrollbarMargin + 'px';
			}

			$this.css(cssToApply);

			var contentHeight = $this.outerHeight();
			var percentInView = paneHeight / contentHeight;

			if (percentInView < .99) {
				var $container = $this.parent();
				$container.append(
					$('<div></div>').attr({'className':'jScrollPaneTrack'}).css({'width':settings.scrollbarWidth+'px'}).append(
						$('<div></div>').attr({'className':'jScrollPaneDrag'}).css({'width':settings.scrollbarWidth+'px'}).append(
							$('<div></div>').attr({'className':'jScrollPaneDragTop'}).css({'width':settings.scrollbarWidth+'px'}),
							$('<div></div>').attr({'className':'jScrollPaneDragBottom'}).css({'width':settings.scrollbarWidth+'px'})
						)
					)
				);
				
				var $track = $('>.jScrollPaneTrack', $container);
				var $drag = $('>.jScrollPaneTrack .jScrollPaneDrag', $container);
				
				if (settings.showArrows) {
					
					var currentArrowButton;
					var currentArrowDirection;
					var currentArrowInterval;
					var currentArrowInc;
					var whileArrowButtonDown = function()
					{
						if (currentArrowInc > 4 || currentArrowInc%4==0) {
							positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier);
						}
						currentArrowInc ++;
					};
					var onArrowMouseUp = function(event)
					{
						$('html').unbind('mouseup', onArrowMouseUp);
						currentArrowButton.removeClass('jScrollActiveArrowButton');
						clearInterval(currentArrowInterval);
					};
					var onArrowMouseDown = function() {
						$('html').bind('mouseup', onArrowMouseUp);
						currentArrowButton.addClass('jScrollActiveArrowButton');
						currentArrowInc = 0;
						whileArrowButtonDown();
						currentArrowInterval = setInterval(whileArrowButtonDown, 100);
					};
					$container
						.append(
							$('<a></a>')
								.attr({'href':'javascript:;', 'className':'jScrollArrowUp'})
								.css({'width':settings.scrollbarWidth+'px'})
								.html('Scroll up')
								.bind('mousedown', function()
								{
									currentArrowButton = $(this);
									currentArrowDirection = -1;
									onArrowMouseDown();
									this.blur();
									return false;
								})
								.bind('click', rf),
							$('<a></a>')
								.attr({'href':'javascript:;', 'className':'jScrollArrowDown'})
								.css({'width':settings.scrollbarWidth+'px'})
								.html('Scroll down')
								.bind('mousedown', function()
								{
									currentArrowButton = $(this);
									currentArrowDirection = 1;
									onArrowMouseDown();
									this.blur();
									return false;
								})
								.bind('click', rf)
						);
					var $upArrow = $('>.jScrollArrowUp', $container);
					var $downArrow = $('>.jScrollArrowDown', $container);
					if (settings.arrowSize) {
						trackHeight = paneHeight - settings.arrowSize - settings.arrowSize;
						$track
							.css({'height': trackHeight+'px', top:settings.arrowSize+'px'})
					} else {
						var topArrowHeight = $upArrow.height();
						settings.arrowSize = topArrowHeight;
						trackHeight = paneHeight - topArrowHeight - $downArrow.height();
						$track
							.css({'height': trackHeight+'px', top:topArrowHeight+'px'})
					}
				}
				
				var $pane = $(this).css({'position':'absolute', 'overflow':'visible'});
				
				var currentOffset;
				var maxY;
				var mouseWheelMultiplier;
				// store this in a seperate variable so we can keep track more accurately than just updating the css property..
				var dragPosition = 0;
				var dragMiddle = percentInView*paneHeight/2;
				
				// pos function borrowed from tooltip plugin and adapted...
				var getPos = function (event, c) {
					var p = c == 'X' ? 'Left' : 'Top';
					return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0;
				};
				
				var ignoreNativeDrag = function() {	return false; };
				
				var initDrag = function()
				{
					ceaseAnimation();
					currentOffset = $drag.offset(false);
					currentOffset.top -= dragPosition;
					maxY = trackHeight - $drag[0].offsetHeight;
					mouseWheelMultiplier = 2 * settings.wheelSpeed * maxY / contentHeight;
				};
				
				var onStartDrag = function(event)
				{
					initDrag();
					dragMiddle = getPos(event, 'Y') - dragPosition - currentOffset.top;
					$('html').bind('mouseup', onStopDrag).bind('mousemove', updateScroll);
					if ($.browser.msie) {
						$('html').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag);
					}
					return false;
				};
				var onStopDrag = function()
				{
					$('html').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll);
					dragMiddle = percentInView*paneHeight/2;
					if ($.browser.msie) {
						$('html').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag);
					}
				};
				var positionDrag = function(destY)
				{
					destY = destY < 0 ? 0 : (destY > maxY ? maxY : destY);
					dragPosition = destY;
					$drag.css({'top':destY+'px'});
					var p = destY / maxY;
					$pane.css({'top':((paneHeight-contentHeight)*p) + 'px'});
					$this.trigger('scroll');
					if (settings.showArrows) {
						$upArrow[destY == 0 ? 'addClass' : 'removeClass']('disabled');
						$downArrow[destY == maxY ? 'addClass' : 'removeClass']('disabled');
					}
				};
				var updateScroll = function(e)
				{
					positionDrag(getPos(e, 'Y') - currentOffset.top - dragMiddle);
				};
				
				var dragH = Math.max(Math.min(percentInView*(paneHeight-settings.arrowSize*2), settings.dragMaxHeight), settings.dragMinHeight);
				
				$drag.css(
					{'height':dragH+'px'}
				).bind('mousedown', onStartDrag);
				
				var trackScrollInterval;
				var trackScrollInc;
				var trackScrollMousePos;
				var doTrackScroll = function()
				{
					if (trackScrollInc > 8 || trackScrollInc%4==0) {
						positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2)));
					}
					trackScrollInc ++;
				};
				var onStopTrackClick = function()
				{
					clearInterval(trackScrollInterval);
					$('html').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove);
				};
				var onTrackMouseMove = function(event)
				{
					trackScrollMousePos = getPos(event, 'Y') - currentOffset.top - dragMiddle;
				};
				var onTrackClick = function(event)
				{
					initDrag();
					onTrackMouseMove(event);
					trackScrollInc = 0;
					$('html').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove);
					trackScrollInterval = setInterval(doTrackScroll, 100);
					doTrackScroll();
				};
				
				$track.bind('mousedown', onTrackClick);
				
				$container.bind(
					'mousewheel',
					function (event, delta) {
						initDrag();
						ceaseAnimation();
						var d = dragPosition;
						positionDrag(dragPosition - delta * mouseWheelMultiplier);
						var dragOccured = d != dragPosition;
						return !dragOccured;
					}
				);

				var _animateToPosition;
				var _animateToInterval;
				function animateToPosition()
				{
					var diff = (_animateToPosition - dragPosition) / settings.animateStep;
					if (diff > 1 || diff < -1) {
						positionDrag(dragPosition + diff);
					} else {
						positionDrag(_animateToPosition);
						ceaseAnimation();
					}
				}
				var ceaseAnimation = function()
				{
					if (_animateToInterval) {
						clearInterval(_animateToInterval);
						delete _animateToPosition;
					}
				};
				var scrollTo = function(pos, preventAni)
				{
					if (typeof pos == "string") {
						$e = $(pos, $this);
						if (!$e.length) return;
						pos = $e.offset().top - $this.offset().top;
					}
					$container.scrollTop(0);
					ceaseAnimation();
					var destDragPosition = -pos/(paneHeight-contentHeight) * maxY;
					if (preventAni || !settings.animateTo) {
						positionDrag(destDragPosition);
					} else {
						_animateToPosition = destDragPosition;
						_animateToInterval = setInterval(animateToPosition, settings.animateInterval);
					}
				};
				$this[0].scrollTo = scrollTo;
				
				$this[0].scrollBy = function(delta)
				{
					var currentPos = -parseInt($pane.css('top')) || 0;
					scrollTo(currentPos + delta);
				};
				
				initDrag();
				
				scrollTo(-currentScrollPosition, true);
			
				// Deal with it when the user tabs to a link or form element within this scrollpane
				$('*', this).bind(
					'focus',
					function(event)
					{
						var $e = $(this);
						
						// loop through parents adding the offset top of any elements that are relatively positioned between
						// the focused element and the jScrollPaneContainer so we can get the true distance from the top
						// of the focused element to the top of the scrollpane...
						var eleTop = 0;
						
						while ($e[0] != $this[0]) {
							eleTop += $e.position().top;
							$e = $e.offsetParent();
						}
						
						var viewportTop = -parseInt($pane.css('top')) || 0;
						var maxVisibleEleTop = viewportTop + paneHeight;
						var eleInView = eleTop > viewportTop && eleTop < maxVisibleEleTop;
						if (!eleInView) {
							var destPos = eleTop - settings.scrollbarMargin;
							if (eleTop > viewportTop) { // element is below viewport - scroll so it is at bottom.
								destPos += $(this).height() + 15 + settings.scrollbarMargin - paneHeight;
							}
							scrollTo(destPos);
						}
					}
				)
				
				
				if (location.hash) {
					scrollTo(location.hash);
				}
				
				// use event delegation to listen for all clicks on links and hijack them if they are links to
				// anchors within our content...
				$(document).bind(
					'click',
					function(e)
					{
						$target = $(e.target);
						if ($target.is('a')) {
							var h = $target.attr('href');
							if (h.substr(0, 1) == '#') {
								scrollTo(h);
							}
						}
					}
				);
				
				$.jScrollPane.active.push($this[0]);
				
			} else {
				$this.css(
					{
						'height':paneHeight+'px',
						'width':paneWidth-this.originalSidePaddingTotal+'px',
						'padding':this.originalPadding
					}
				);
				// remove from active list?
				$this.parent().unbind('mousewheel');
			}
			
		}
	)
};

$.fn.jScrollPane.defaults = {
	scrollbarWidth : 10,
	scrollbarMargin : 0,
	wheelSpeed : 18,
	showArrows : false,
	arrowSize : 0,
	animateTo : false,
	dragMinHeight : 1,
	dragMaxHeight : 99999,
	animateInterval : 100,
	animateStep: 3,
	maintainPosition: true,
	scrollbarOnLeft: false,
	reinitialiseOnImageLoad: false
};

// clean up the scrollTo expandos
$(window)
	.bind('unload', function() {
		var els = $.jScrollPane.active; 
		for (var i=0; i<els.length; i++) {
			els[i].scrollTo = els[i].scrollBy = null;
		}
	}
);

})(jQuery);
*/
/* end jScrollPane */























/* innerfade */

(function($) {

	$.fn.innerfade = function(options) {
		return this.each(function() {   
			$.innerfade(this, options);
		});
	};

	$.innerfade = function(container, options) {
		var settings = {
			'animationtype':    'fade',
			'speed':            'normal',
			'type':             'sequence',
			'timeout':          2000,
			'containerheight':  'auto',
			'runningclass':     'innerfade',
			'children':         null
		};
		if (options)
			$.extend(settings, options);
		if (settings.children === null)
			var elements = $(container).children();
		else
			var elements = $(container).children(settings.children);
		if (elements.length > 1) {
			$(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
			for (var i = 0; i < elements.length; i++) {
				$(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
			};
			if (settings.type == "sequence") {
				setTimeout(function() {
					$.innerfade.next(elements, settings, 1, 0);
				}, settings.timeout);
				$(elements[0]).show();
			} else if (settings.type == "random") {
					var last = Math.floor ( Math.random () * ( elements.length ) );
				setTimeout(function() {
					do { 
												current = Math.floor ( Math.random ( ) * ( elements.length ) );
										} while (last == current );             
										$.innerfade.next(elements, settings, current, last);
				}, settings.timeout);
				$(elements[last]).show();
						} else if ( settings.type == 'random_start' ) {
								settings.type = 'sequence';
								var current = Math.floor ( Math.random () * ( elements.length ) );
								setTimeout(function(){
									$.innerfade.next(elements, settings, (current + 1) %  elements.length, current);
								}, settings.timeout);
								$(elements[current]).show();
						}	else {
							alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
						}
				}
	};

	$.innerfade.next = function(elements, settings, current, last) {
		if (settings.animationtype == 'slide') {
			$(elements[last]).slideUp(settings.speed);
			$(elements[current]).slideDown(settings.speed);
		} else if (settings.animationtype == 'fade') {
			$(elements[last]).fadeOut(settings.speed);
			$(elements[current]).fadeIn(settings.speed, function() {
							removeFilter($(this)[0]);
						});
		} else
			alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
		if (settings.type == "sequence") {
			if ((current + 1) < elements.length) {
				current = current + 1;
				last = current - 1;
			} else {
				current = 0;
				last = elements.length - 1;
			}
		} else if (settings.type == "random") {
			last = current;
				current = Math.floor(Math.random() * elements.length);
			while (current == last);
		} else 
			alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
		
		setTimeout((function() {
			$.innerfade.next(elements, settings, current, last);
		}), settings.timeout);
	};

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
	if(element.style.removeAttribute){
		element.style.removeAttribute('filter');
	}
}

/* end innerfade */

/* mousewheel */

(function(b){function d(a){var f=[].slice.call(arguments,1),e=0;a=b.event.fix(a||window.event);a.type="mousewheel";if(a.wheelDelta)e=a.wheelDelta/120;if(a.detail)e=-a.detail/3;f.unshift(a,e);return b.event.handle.apply(this,f)}var c=["DOMMouseScroll","mousewheel"];b.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=c.length;a;)this.addEventListener(c[--a],d,false);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=c.length;a;)this.removeEventListener(c[--a],
d,false);else this.onmousewheel=null}};b.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);

/* end mousewheel */

/* simplemodal */
(function($){var ie6=$.browser.msie&&parseInt($.browser.version)==6&&typeof window['XMLHttpRequest']!="object",ieQuirks=null,w=[];$.modal=function(data,options){return $.modal.impl.init(data,options);};$.modal.close=function(){$.modal.impl.close();};$.fn.modal=function(options){return $.modal.impl.init(this,options);};$.modal.defaults={appendTo:'body',focus:true,opacity:50,overlayId:'simplemodal-overlay',overlayCss:{},containerId:'simplemodal-container',containerCss:{},dataId:'simplemodal-data',dataCss:{},minHeight:null,minWidth:null,maxHeight:null,maxWidth:null,autoResize:false,autoPosition:true,zIndex:1000,close:true,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:'simplemodal-close',escClose:true,overlayClose:false,position:null,persist:false,transient:false,onOpen:null,onShow:null,onClose:null};$.modal.impl={o:null,d:{},init:function(data,options){var s=this;if(s.d.data){return false;}ieQuirks=$.browser.msie&&!$.support.boxModel;s.o=$.extend({},$.modal.defaults,options);s.zIndex=s.o.zIndex;s.occb=false;if(typeof data=='object'){data=data instanceof jQuery?data:$(data);s.d.placeholder=false;if(data.parent().parent().size()>0){data.before($('<span></span>').attr('id','simplemodal-placeholder').css({display:'none'}));s.d.placeholder=true;s.display=data.css('display');if(!s.o.persist){s.d.orig=data.clone(true);}}}else if(typeof data=='string'||typeof data=='number'){data=$('<div></div>').html(data);}else{alert('SimpleModal Error: Unsupported data type: '+typeof data);return s;}s.create(data);data=null;s.open();if($.isFunction(s.o.onShow)){s.o.onShow.apply(s,[s.d]);}return s;},create:function(data){var s=this;w=s.getDimensions();if(!s.o.transient&&ie6){s.d.iframe=$('<iframe src="javascript:false;"></iframe>').css($.extend(s.o.iframeCss,{display:'none',opacity:0,position:'fixed',height:w[0],width:w[1],zIndex:s.o.zIndex,top:0,left:0})).appendTo(s.o.appendTo);}s.d.overlay=$('<div></div>').attr('id',s.o.overlayId).addClass('simplemodal-overlay').css($.extend(s.o.overlayCss,{display:'none',opacity:s.o.opacity/100,height:s.o.transient?0:w[0],width:s.o.transient?0:w[1],position:'fixed',left:0,top:0,zIndex:s.o.zIndex+1})).appendTo(s.o.appendTo);s.d.container=$('<div></div>').attr('id',s.o.containerId).addClass('simplemodal-container').css($.extend(s.o.containerCss,{display:'none',position:'fixed',zIndex:s.o.zIndex+2})).append(s.o.close&&s.o.closeHTML?$(s.o.closeHTML).addClass(s.o.closeClass):'').appendTo(s.o.appendTo);s.d.wrap=$('<div></div>').attr('tabIndex',-1).addClass('simplemodal-wrap').css({height:'100%',outline:0,width:'100%'}).appendTo(s.d.container);s.d.data=data.attr('id',data.attr('id')||s.o.dataId).addClass('simplemodal-data').css($.extend(s.o.dataCss,{display:'none'})).appendTo('body');data=null;s.setContainerDimensions();s.d.data.appendTo(s.d.wrap);if(ie6||ieQuirks){s.fixIE();}},bindEvents:function(){var s=this;$('.'+s.o.closeClass).bind('click.simplemodal',function(e){e.preventDefault();s.close();});if(!s.o.transient&&s.o.close&&s.o.overlayClose){s.d.overlay.bind('click.simplemodal',function(e){e.preventDefault();s.close();});}$(document).bind('keydown.simplemodal',function(e){if(!s.o.transient&&s.o.focus&&e.keyCode==9){s.watchTab(e);}else if((s.o.close&&s.o.escClose)&&e.keyCode==27){e.preventDefault();s.close();}});$(window).bind('resize.simplemodal',function(){w=s.getDimensions();s.setContainerDimensions(true);if(ie6||ieQuirks){s.fixIE();}else if(!s.o.transient){s.d.iframe&&s.d.iframe.css({height:w[0],width:w[1]});s.d.overlay.css({height:w[0],width:w[1]});}});},unbindEvents:function(){$('.'+this.o.closeClass).unbind('click.simplemodal');$(document).unbind('keydown.simplemodal');$(window).unbind('resize.simplemodal');this.d.overlay.unbind('click.simplemodal');},fixIE:function(){var s=this,p=s.o.position;$.each([s.d.iframe||null,s.o.transient?null:s.d.overlay,s.d.container],function(i,el){if(el){var bch='document.body.clientHeight',bcw='document.body.clientWidth',bsh='document.body.scrollHeight',bsl='document.body.scrollLeft',bst='document.body.scrollTop',bsw='document.body.scrollWidth',ch='document.documentElement.clientHeight',cw='document.documentElement.clientWidth',sl='document.documentElement.scrollLeft',st='document.documentElement.scrollTop',s=el[0].style;s.position='absolute';if(i<2){s.removeExpression('height');s.removeExpression('width');s.setExpression('height',''+bsh+' > '+bch+' ? '+bsh+' : '+bch+' + "px"');s.setExpression('width',''+bsw+' > '+bcw+' ? '+bsw+' : '+bcw+' + "px"');}else{var te,le;if(p&&p.constructor==Array){var top=p[0]?typeof p[0]=='number'?p[0].toString():p[0].replace(/px/,''):el.css('top').replace(/px/,'');te=top.indexOf('%')==-1?top+' + (t = '+st+' ? '+st+' : '+bst+') + "px"':parseInt(top.replace(/%/,''))+' * (('+ch+' || '+bch+') / 100) + (t = '+st+' ? '+st+' : '+bst+') + "px"';if(p[1]){var left=typeof p[1]=='number'?p[1].toString():p[1].replace(/px/,'');le=left.indexOf('%')==-1?left+' + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"':parseInt(left.replace(/%/,''))+' * (('+cw+' || '+bcw+') / 100) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}}else{te='('+ch+' || '+bch+') / 2 - (this.offsetHeight / 2) + (t = '+st+' ? '+st+' : '+bst+') + "px"';le='('+cw+' || '+bcw+') / 2 - (this.offsetWidth / 2) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}s.removeExpression('top');s.removeExpression('left');s.setExpression('top',te);s.setExpression('left',le);}}});},focus:function(pos){var s=this,p=pos||'first';var input=$(':input:enabled:visible:'+p,s.d.wrap);input.length>0?input.focus():s.d.wrap.focus();},getDimensions:function(){var el=$(window);var h=$.browser.opera&&$.browser.version>'9.5'&&$.fn.jquery<='1.2.6'?document.documentElement['clientHeight']:$.browser.opera&&$.browser.version<'9.5'&&$.fn.jquery>'1.2.6'?window.innerHeight:el.height();return[h,el.width()];},getVal:function(v){return v=='auto'?0:v.indexOf('%')>0?v:parseInt(v.replace(/px/,''));},setContainerDimensions:function(resize){var s=this;if(!resize||(resize&&s.o.autoResize)){var ch=$.browser.opera?s.d.container.height():s.getVal(s.d.container.css('height')),cw=$.browser.opera?s.d.container.width():s.getVal(s.d.container.css('width')),dh=s.d.data.outerHeight(true),dw=s.d.data.outerWidth(true);var mh=s.o.maxHeight&&s.o.maxHeight<w[0]?s.o.maxHeight:w[0],mw=s.o.maxWidth&&s.o.maxWidth<w[1]?s.o.maxWidth:w[1];if(!ch){if(!dh){ch=s.o.minHeight;}else{if(dh>mh){ch=mh;}else if(dh<s.o.minHeight){ch=s.o.minHeight;}else{ch=dh;}}}else{ch=ch>mh?mh:ch;}if(!cw){if(!dw){cw=s.o.minWidth;}else{if(dw>mw){cw=mw;}else if(dw<s.o.minWidth){cw=s.o.minWidth;}else{cw=dw;}}}else{cw=cw>mw?mw:cw;}s.d.container.css({height:ch,width:cw});if(dh>ch||dw>cw){s.d.wrap.css({overflow:'auto'});}}if(s.o.autoPosition){s.setPosition();}},setPosition:function(){var s=this,top,left,hc=(w[0]/2)-(s.d.container.outerHeight(true)/2),vc=(w[1]/2)-(s.d.container.outerWidth(true)/2);if(s.o.position&&Object.prototype.toString.call(s.o.position)==="[object Array]"){top=s.o.position[0]||hc;left=s.o.position[1]||vc;}else{top=hc;left=vc;}s.d.container.css({left:left,top:top});},watchTab:function(e){var s=this;if($(e.target).parents('.simplemodal-container').length>0){s.inputs=$(':input:enabled:visible:first, :input:enabled:visible:last',s.d.data[0]);if((!e.shiftKey&&e.target==s.inputs[s.inputs.length-1])||(e.shiftKey&&e.target==s.inputs[0])||s.inputs.length==0){e.preventDefault();var pos=e.shiftKey?'last':'first';setTimeout(function(){s.focus(pos);},10);}}else{e.preventDefault();setTimeout(function(){s.focus();},10);}},open:function(){var s=this;s.d.iframe&&s.d.iframe.show();if($.isFunction(s.o.onOpen)){s.o.onOpen.apply(s,[s.d]);}else{s.d.overlay.show();s.d.container.show();s.d.data.show();}s.focus();s.bindEvents();},close:function(){var s=this;if(!s.d.data){return false;}s.unbindEvents();if($.isFunction(s.o.onClose)&&!s.occb){s.occb=true;s.o.onClose.apply(s,[s.d]);}else{if(s.d.placeholder){var ph=$('#simplemodal-placeholder');if(s.o.persist){ph.replaceWith(s.d.data.removeClass('simplemodal-data').css('display',s.display));}else{s.d.data.hide().remove();ph.replaceWith(s.d.orig);}}else{s.d.data.hide().remove();}s.d.container.hide().remove();s.d.overlay.hide().remove();s.d.iframe&&s.d.iframe.hide().remove();s.d={};}}};})(jQuery);
/* end simplemodal */

/* maskedinput */
(function(a){var c=(a.browser.msie?"paste":"input")+".mask";var b=(window.orientation!=undefined);a.mask={definitions:{"9":"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"}};a.fn.extend({caret:function(e,f){if(this.length==0){return}if(typeof e=="number"){f=(typeof f=="number")?f:e;return this.each(function(){if(this.setSelectionRange){this.focus();this.setSelectionRange(e,f)}else{if(this.createTextRange){var g=this.createTextRange();g.collapse(true);g.moveEnd("character",f);g.moveStart("character",e);g.select()}}})}else{if(this[0].setSelectionRange){e=this[0].selectionStart;f=this[0].selectionEnd}else{if(document.selection&&document.selection.createRange){var d=document.selection.createRange();e=0-d.duplicate().moveStart("character",-100000);f=e+d.text.length}}return{begin:e,end:f}}},unmask:function(){return this.trigger("unmask")},mask:function(j,d){if(!j&&this.length>0){var f=a(this[0]);var g=f.data("tests");return a.map(f.data("buffer"),function(l,m){return g[m]?l:null}).join("")}d=a.extend({placeholder:"_",completed:null},d);var k=a.mask.definitions;var g=[];var e=j.length;var i=null;var h=j.length;a.each(j.split(""),function(m,l){if(l=="?"){h--;e=m}else{if(k[l]){g.push(new RegExp(k[l]));if(i==null){i=g.length-1}}else{g.push(null)}}});return this.each(function(){var r=a(this);var m=a.map(j.split(""),function(x,y){if(x!="?"){return k[x]?d.placeholder:x}});var n=false;var q=r.val();r.data("buffer",m).data("tests",g);function v(x){while(++x<=h&&!g[x]){}return x}function t(x){while(!g[x]&&--x>=0){}for(var y=x;y<h;y++){if(g[y]){m[y]=d.placeholder;var z=v(y);if(z<h&&g[y].test(m[z])){m[y]=m[z]}else{break}}}s();r.caret(Math.max(i,x))}function u(y){for(var A=y,z=d.placeholder;A<h;A++){if(g[A]){var B=v(A);var x=m[A];m[A]=z;if(B<h&&g[B].test(x)){z=x}else{break}}}}function l(y){var x=a(this).caret();var z=y.keyCode;n=(z<16||(z>16&&z<32)||(z>32&&z<41));if((x.begin-x.end)!=0&&(!n||z==8||z==46)){w(x.begin,x.end)}if(z==8||z==46||(b&&z==127)){t(x.begin+(z==46?0:-1));return false}else{if(z==27){r.val(q);r.caret(0,p());return false}}}function o(B){if(n){n=false;return(B.keyCode==8)?false:null}B=B||window.event;var C=B.charCode||B.keyCode||B.which;var z=a(this).caret();if(B.ctrlKey||B.altKey||B.metaKey){return true}else{if((C>=32&&C<=125)||C>186){var x=v(z.begin-1);if(x<h){var A=String.fromCharCode(C);if(g[x].test(A)){u(x);m[x]=A;s();var y=v(x);a(this).caret(y);if(d.completed&&y==h){d.completed.call(r)}}}}}return false}function w(x,y){for(var z=x;z<y&&z<h;z++){if(g[z]){m[z]=d.placeholder}}}function s(){return r.val(m.join("")).val()}function p(y){var z=r.val();var C=-1;for(var B=0,x=0;B<h;B++){if(g[B]){m[B]=d.placeholder;while(x++<z.length){var A=z.charAt(x-1);if(g[B].test(A)){m[B]=A;C=B;break}}if(x>z.length){break}}else{if(m[B]==z[x]&&B!=e){x++;C=B}}}if(!y&&C+1<e){r.val("");w(0,h)}else{if(y||C+1>=e){s();if(!y){r.val(r.val().substring(0,C+1))}}}return(e?B:i)}if(!r.attr("readonly")){r.one("unmask",function(){r.unbind(".mask").removeData("buffer").removeData("tests")}).bind("focus.mask",function(){q=r.val();var x=p();s();setTimeout(function(){if(x==j.length){r.caret(0,x)}else{r.caret(x)}},0)}).bind("blur.mask",function(){p();if(r.val()!=q){r.change()}}).bind("keydown.mask",l).bind("keypress.mask",o).bind(c,function(){setTimeout(function(){r.caret(p(true))},0)})}p()})}})})(jQuery);
/* end maskedinput */

/*---------------------- rating --------------------------------*/



/*----------------------------end rating------------------------*/